# Reference: <https://postmarketos.org/devicepkg>
# Maintainer: Raymond Hackley <raymondhackley@protonmail.com>
pkgname=device-qcom-msm8909
pkgdesc="Generic device package for various Qualcomm MSM8905/MSM8909/MSM8916-based devices"
pkgver=2
pkgrel=0
url="https://postmarketos.org"
license="MIT"
arch="armv7"
options="!check !archcheck"
depends="
	linux-postmarketos-qcom-msm8916
	postmarketos-base
	soc-qcom-msm8909
"
makedepends="devicepkg-dev"
source="
	deviceinfo
	modules-initfs
"
subpackages="$pkgname-nonfree-firmware:nonfree_firmware"

build() {
	devicepkg_build $startdir $pkgname
}

package() {
	devicepkg_package $startdir $pkgname
}

nonfree_firmware() {
	pkgdesc="WiFi/BT/Modem/Video firmware"
	depends="msm-firmware-loader firmware-qcom-adreno-a300 firmware-qcom-db410c-wcnss-nv"
	mkdir "$subpkgdir"

	# HACK: For devices that don't have a nv file in persist we
	# temporarily link the db410c file to the expected location.
	# It will be overriden if the file is in persist or when user
	# installs the device-specific firmware packages.
	mkdir -p "$subpkgdir"/lib/firmware/wlan/prima/
	ln -s /lib/firmware/qcom/apq8016/WCNSS_qcom_wlan_nv_sbc.bin \
		"$subpkgdir"/lib/firmware/wlan/prima/WCNSS_qcom_wlan_nv.bin
}

sha512sums="
93cbd664d37f63ac142e03ab9168bc94a8cde1880d88b12d17b94fb9318a330434df427878be3af4d96c0bb156beaeb41741a9cf42f557c5a160837a62f1233c  deviceinfo
3c4ae8aad562270a6094add613912955bafed994e0df2f8842575fb4e38db0f21a57dc61fb772af418d1423512811e7f9f533c2e9b3f8edb657ed20f12ca2fc9  modules-initfs
"
